import Vue from 'vue'
import App from './App.vue'
import router from './router'
// 导入全局样式表
import './assets/css/global_css.css'
import ElementUI from 'element-ui'
import locale from 'element-ui/lib/locale/lang/zh-CN'
import 'element-ui/lib/theme-chalk/index.css'
// 导入table with tree组件
import TreeTable from 'vue-table-with-tree-grid'
// 全局导入富文本模块
import VueQuillEditor from 'vue-quill-editor'

import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

Vue.use(VueQuillEditor, /* { default global options } */ )
Vue.component('tree-table', TreeTable)
    //导入字体图标
import './assets/font/iconfont.css'

//导入axios以及配置axios
import axios from 'axios'
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
Vue.prototype.$http = axios;
import NProgress from 'nprogress'
import 'nprogress/nprogress.css' //这个样式必须引入
// nprogress配置
NProgress.inc(0.2)
NProgress.configure({ easing: 'ease', speed: 500, showSpinner: false })

// 挂载nprogress
router.beforeEach((to, from, next) => {
    NProgress.start()
    next()
})

router.afterEach(() => {
        NProgress.done()
    })
    //设置请求头拦截器 为请求头添加 Authorization
axios.interceptors.request.use(config => {
    //在请求头里面添加Authorization属性
    config.headers.Authorization = window.sessionStorage.getItem('token')
        //返回请求里的数据
    return config
})

Vue.use(ElementUI, { locale })
Vue.config.productionTip = false

new Vue({
    router,
    render: h => h(App)
}).$mount('#app')